//
//  GKZYUniversityAcceptHeaderView.m
//  GKZYAid
//
//  Created by Tony Zhang on 16/3/14.
//  Copyright © 2016年 GKZYAid. All rights reserved.
//

#import "GKZYUniversityAcceptHeaderView.h"
#import "MyDefine.h"
#import <CorePlot.h>
#import "GKZYUniversityScoreBarPlotView.h"
#import "GKZYUniversityScoreModel.h"
#import "GKZYUniversityMajoreScoreView.h"
#import "GKZYUserSortDataHandel.h"


@interface GKZYUniversityAcceptHeaderView ()

@end

@implementation GKZYUniversityAcceptHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
       
    }
    return self;
}


-(void)configureTheViewWithModel:(GKYUniversityAcceptModel *)model{
   
     GKZYUniversityCustomCircleView *circleView = [[GKZYUniversityCustomCircleView alloc]init];
     circleView.frame = CGRectMake(20, 10, 100, 100);
     circleView.progressColor = [UIColor orangeColor];
     circleView.progressStrokeWidth = 5.0f;
     circleView.progressTrackColor = CustomGrayColor;
     circleView.progressValue = [model.safe_ratio floatValue];
     [self addSubview:circleView];
    
    UILabel *label = [[UILabel alloc]init];
    label.frame = CGRectMake(30, CGRectGetMaxY(circleView.frame)+20, 120, 30);
    label.text = @"录取概率";
    label.textAlignment = NSTextAlignmentCenter;
    [self addSubview: label];
    
    UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(KmainScreenBoundsWidth/2-2, 20, 4, 100)];
    lable.backgroundColor = CustomGrayColor;
    [self addSubview:lable];
    
    UILabel *label1 = [[UILabel alloc]init];
    label1.frame = CGRectMake(KmainScreenBoundsWidth/2 ,CGRectGetMinY(label.frame), KmainScreenBoundsWidth/2, 30);
    label1.textAlignment = NSTextAlignmentCenter;
    label1.text = @"成绩分析";
    [self addSubview:label1];
    
    UILabel *markLabe = [[UILabel alloc]init];
    NSString *str1 = @"超过";
    markLabe.font = [UIFont systemFontOfSize:12];
    CGSize size = [str1 sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:markLabe.font,NSFontAttributeName, nil]];
    markLabe.frame = CGRectMake(KmainScreenBoundsWidth/2+20,60, size.width, 30);
    markLabe.text = str1;
    [self addSubview:markLabe];
    
    UILabel *ratioLab = [[UILabel alloc]init];
    ratioLab.font = [UIFont systemFontOfSize:20];
    NSString *str2 = [NSString stringWithFormat:@"%.0f",[model.major_ratio floatValue]*100];
    NSString *str3 = @"%";
    NSString *string = [str2 stringByAppendingString:str3];
    CGSize size1 = [string sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:ratioLab.font,NSFontAttributeName, nil]];
    ratioLab.text = string;
    ratioLab.textColor = [UIColor orangeColor];
    ratioLab.frame = CGRectMake(CGRectGetMaxX(markLabe.frame), 60, size1.width, 30);
    [self addSubview:ratioLab];
    
    UILabel *strLab = [[UILabel alloc]init];
    strLab.frame = CGRectMake(CGRectGetMaxX(ratioLab.frame), 60, KmainScreenBoundsWidth/2-60, 30);
    strLab.font = [UIFont systemFontOfSize:12];
    strLab.text = @"的同批考生";
    [self addSubview:strLab];
    
    UILabel *scoreLable = [[UILabel alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(label1.frame)+20, KmainScreenBoundsWidth -20, 30)];
    scoreLable.text = @"往年录取平均分";
    [self addSubview:scoreLable];
    
    NSMutableArray *dataArray = [[NSMutableArray alloc]init];
    for (NSDictionary *dict in model.score_list) {
        GKZYUniversityScoreModel *model = [[GKZYUniversityScoreModel alloc]init];
        [model setValuesForKeysWithDictionary:dict];
        [dataArray addObject:model];
    }
    
    GKZYUniversityScoreModel *model0 = [[GKZYUniversityScoreModel alloc]init];
    model0.year = @"我的成绩";
    model0.avg_score = SINGLETON.score;
    [dataArray addObject:model0];
    
    GKZYUniversityScoreBarPlotView *scoreBar = [[GKZYUniversityScoreBarPlotView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(scoreLable.frame), KmainScreenBoundsWidth, 210)];
    [scoreBar configureTheViewWithArray:dataArray];
    [self addSubview:scoreBar];
    
    UILabel *majorLab = [[UILabel alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(scoreBar.frame)+10, KmainScreenBoundsWidth-20, 30)];
    majorLab.text = @"在招专业录取平均分";
    [self addSubview:majorLab];
    CALayer *layer = [CALayer layer];
    layer.borderColor = DeepCustomGrayColor.CGColor;
    layer.borderWidth = 0.5f;
    layer.frame = CGRectMake(-10, 0, KmainScreenBoundsWidth, 0.5);
    [majorLab.layer addSublayer:layer];
    
    CALayer *layer1 = [CALayer layer];
    layer1.borderColor = DeepCustomGrayColor.CGColor;
    layer1.borderWidth = 0.5f;
    layer1.frame = CGRectMake(-10, 30, KmainScreenBoundsWidth, 0.5);
    [majorLab.layer addSublayer:layer1];
    
    GKZYUniversityMajoreScoreView *view = [[GKZYUniversityMajoreScoreView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(majorLab.frame), KmainScreenBoundsWidth, 30)];
    NSArray *array = @[@"2012",@"2013",@"2014"];
    [view confirgureTheViewWithMajorName:@"专业名称" DataArray:array];
    view.backgroundColor = CustomGrayColor;
    [self addSubview:view];
    
}


@end
